package middleware

import (
	"awesomeProject1/services/mq/kafka"
	"github.com/gin-gonic/gin"
	"time"
)

func TimeoutAlertMiddleware() gin.HandlerFunc {
	return func(c *gin.Context) {
		start := time.Now().Second()
		c.Next()
		end := time.Now().Second()
		if end >= (start + 6) {
			reqUrl := c.Request.RequestURI
			kafka.SendMsg("接口超时，请排查, " + reqUrl)
		}
	}
}
